﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DSkin;
using DSkin.Forms;
using CefSharp;
using CefSharp.WinForms;
using System.Threading;

namespace wfaResClient
{
    public partial class FrmLogin : DSkinForm
    {
        public static FrmLogin fl;
        JavascriptCsharp jc = new JavascriptCsharp();
        public FrmLogin()
        {
            InitializeComponent();
            fl = this;
            InitializeBrowserControl();
        }
        ChromiumWebBrowser browser;
        public void InitializeBrowserControl()
        {
            browser = new ChromiumWebBrowser(jc.GetPagePath("login.html"))
            {
                Dock = DockStyle.Fill
            };
            controlHost1.Controls.Add(browser);
            Control.CheckForIllegalCrossThreadCalls = false;
            CefSharpSettings.LegacyJavascriptBindingEnabled = true;
            browser.RegisterJsObject("login",new LoginClass());//注册js事件
        }
    }
    class LoginClass
    {
        public void LoginID(string Name,string loginID)
        {
            PublicData.Name = Name;//记录登录成功的ID
            PublicData.LoginID = loginID;//ID账号
            FrmLogin.fl.Close();
        }
    }
}
